package com.quasar.hpatient.presenter;

import com.quasar.hpatient.model.httpmodel.AnotherResult;
import com.quasar.hpatient.model.httpmodel.DataStateResult;
import com.quasar.hpatient.model.medicalmodel.DiscomfortData;
import com.quasar.hpatient.model.requestmodel.RequestModel;
import com.quasar.hpatient.onInterface.AnotherResultListener;
import com.quasar.hpatient.onInterface.OnDataResultListener;
import com.vise.log.ViseLog;

/**
 * author : 许建宏
 * Date: 2017/10/31 0031
 * View:单日不适症状获取
 */

public class DiscomfortPresenter {

    private RequestModel requestModel;
    private OnDataResultListener uiInterface;

    public DiscomfortPresenter(OnDataResultListener uiInterface) {
        this.requestModel = new RequestModel();
        this.uiInterface = uiInterface;
    }

    //查询当日不适症状
    public void PostDiscomfortData(String endTime,String recordTime){
        requestModel.DiscomfortData(endTime, recordTime, new AnotherResultListener<AnotherResult<DiscomfortData>>() {
            @Override
            public void onSuccess(AnotherResult<DiscomfortData> data) {
                uiInterface.onViewFirstSuccess(data);
            }

            @Override
            public void onError(String msg) {
                uiInterface.onViewError(msg);
            }

            @Override
            public void onRefreshUI() {
                uiInterface.onViewRefreshListSuccess();
            }
        });
    }
    //查询上次不适症状信息
    public void GetRecentTroubleData(String recordTime){

        requestModel.GetRecentTroubleData(recordTime, new AnotherResultListener<AnotherResult<DiscomfortData>>() {
            @Override
            public void onSuccess(AnotherResult<DiscomfortData> data) {
                uiInterface.onViewNextSuccess(data);
            }

            @Override
            public void onError(String msg) {
                uiInterface.onViewError(msg);
            }

            @Override
            public void onRefreshUI() {
                uiInterface.onViewRefreshUI();
            }
        });
    }

    //不适症状提交
    public void AddTroubleDetailPost(String description,String list,String longTime,String durationLength){

        requestModel.AddTroubleDetailData("",description,list,longTime,durationLength,new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {
                uiInterface.onSubSymptoms(data);
            }

            @Override
            public void onError(String msg) {
                uiInterface.onViewError(msg);
            }

            @Override
            public void onRefreshUI() {
                uiInterface.onViewRefreshUI();
            }
        });
    }

    //修改事件描述

    public void AmmTroubleDetailServer(String troubleName,String durationLength,String logTime,String description,String id){
        requestModel.AmmTroubleDetailServer(troubleName, durationLength, logTime, description,id, new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {
//                uiInterface.onUpdateDescribe(data);
                uiInterface.onSubSymptoms(data);
            }

            @Override
            public void onError(String msg) {
                uiInterface.onViewError(msg);
                ViseLog.d("修改事件描述"+msg);
            }

            @Override
            public void onRefreshUI() {
                uiInterface.onViewRefreshUI();
            }
        });
    }

    //删除不适症状信息
    public void DeleteEvent(String id){

        requestModel.DeleteEvent(id, new AnotherResultListener<DataStateResult>() {
            @Override
            public void onSuccess(DataStateResult data) {
                uiInterface.onSubSymptoms(data);
            }

            @Override
            public void onError(String msg) {
                uiInterface.onViewError(msg);
            }

            @Override
            public void onRefreshUI() {
                uiInterface.onViewRefreshUI();
            }
        });
    }


}
